import 'package:flutter/material.dart';

class CommonButtonView extends StatefulWidget {
  final String title;
  final Function onPress;
  final double marginBottom;
  final bool vanish;

  CommonButtonView(this.title, this.onPress,
      {this.vanish = false, this.marginBottom = 20});

  @override
  _CommonButtonViewState createState() => _CommonButtonViewState();
}

class _CommonButtonViewState extends State<CommonButtonView> {
  @override
  Widget build(BuildContext context) {
    return Positioned(
        bottom: widget.marginBottom,
        child: Offstage(
          offstage: widget.vanish,
          child: Container(
            width: MediaQuery.of(context).size.width - 40,
            margin: EdgeInsets.only(left: 20, right: 20),
            child: FractionallySizedBox(
              child: GestureDetector(
                  child: RaisedButton(
                highlightColor: Colors.blueAccent,
                splashColor: Colors.purple,
                color: Colors.blue,
                onPressed: widget.onPress,
                child: Text(
                  widget.title,
                  style: TextStyle(color: Colors.white),
                ),
              )),
            ),
          ),
        ));
  }
}
